Ext.define('js.foundation.foundationAddPage', {
    extend: 'Ext.form.Panel',
    requires: ['js.Util', 'js.ctrl.Common'],
    controller: 'Common',
    config: {
        bodyPadding: '20 20 20 20',
        layout: {
            type: 'vbox',
            align: 'stretch'
        }
    },
    hidenField: {
        region_id: undefined
    },
    defaults: {
        labelWidth:150,
        flex:1,
        allowBlank: false
    },
    url: 'progressRoutes',
    initComponent: function () {

        Ext.QuickTips.init();
        Ext.form.Field.prototype.msgTarget = 'under';

        Ext.apply(Ext.form.VTypes,{
            mobilephone:function(val,field)
            {
                try
                {
                    if(/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(val))
                        return true;
                }
                catch(e)
                {
                    return false;
                }
            },
            mobilephoneText:'请输入正确的手机号码',
        });
        let basicInformationList={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'datefield',
                editable:false,
                name: 'inspection_date',
                id: 'inspection_date',
                allowBlank: false,
                value:this.inspection_date,
                msgTarget : 'qtip',
                width: '50%',
                margin:'10 0 10 0',
                labelSeparator: '',
                fieldLabel: '报验日期:'
            },/*{
                xtype: 'textfield',
                name: 'reporter_id',
                id: 'user_id_bbr',
                allowBlank: false,
                value:this.reporter_id,

                hidden:true
            },*/{
                xtype: 'textfield',
                name: 'reporter_name',
                id: 'user_name_bbr',
                value:this.reporter_name,
                allowBlank: false,
                msgTarget : 'qtip',
                width: '50%',
                margin:'10 0 10 0',
                labelWidth:130,
                labelSeparator: '',
                fieldLabel: '<span style="margin-left:30px; ">报验人</span>:',
            /*    listeners: {
                    render: function(p) {
                        p.getEl().on('click', function(p){
                            let a = Ext.getCmp('BasGraphAddWindow');
                            if(a) a.remove(a);
                            let formPanel = Ext.create('js.basicInformation.BasGraphAddWindow',{
                                idA:'user_id_bbr',
                                nameA:'user_name_bbr',
                                actionType:'dan'
                            });
                            let win = util.window(formPanel, {title:'添加报备人员' ,width:'600',height:'600'});
                            win.show();
                        });
                    }}*/
            }
            ]

        }
        let basicInformationListA={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'textfield',
                name: 'inspection_name',
                id: 'inspection_name',
                allowBlank: false,
                width: '50%',
                msgTarget : 'qtip',
                value:this.inspection_name,
                margin:'5 0 10 0',
                labelSeparator: '',
                fieldLabel: '报验资料名:'
            },{
                xtype: 'textfield',
                name: 'inspection_no',
                width: '50%',
                id: 'inspection_no',
                allowBlank: false,
                msgTarget : 'qtip',
                labelWidth:130,
                value:this.mobile,
                margin:'10 0 10 0',
                vtype: "mobilephone",//自定义的验证类型
                labelSeparator: '',
                fieldLabel: '<span style="margin-left:30px; ">报验人电话:</span>'
            }
            ]

        }
        let basicInformationListAA={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'datefield',
                editable:false,
                name: 'supervision_date',
                id: 'supervision_date',
                allowBlank: false,
                value:this.supervision_date,
                msgTarget : 'qtip',
                margin:'10 0 10 0',
                labelSeparator: '',
                width: '50%',
                fieldLabel: '监督日期:'
            },{
                xtype: 'textfield',
                name: 'supervisor_id',
                id: 'supervisor_id_jdr',
                value:this.supervisor_id,
                hidden:true,
            },{
                xtype: 'textfield',
                name: 'supervisor_name',
                id: 'supervisor_name_jdr',
                width: '50%',
                labelWidth:130,
                value:this.supervisor_name,
                allowBlank: false,
                msgTarget : 'qtip',
                margin:'10 0 10 0',
                labelSeparator: '',
                fieldLabel: '<span style="margin-left:30px; ">监督人</span>:',
                listeners: {
                    render: function(p) {
                        p.getEl().on('click', function(p){
                            let a = Ext.getCmp('BasGraphAddWindow');
                            if(a) a.remove(a);
                            let formPanel = Ext.create('js.basicInformation.BasGraphAddWindow',{
                                idA:'supervisor_id_jdr',
                                nameA:'supervisor_name_jdr',
                                actionType:'duoccry'
                            });
                            let win = util.window(formPanel, {title:'添加抽查人员' ,width:'600',height:'600'});
                            win.show();
                        });
                    }}
            }
            ]

        }
        let basicInformationListB={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            flex:2,
            items:[ {
                xtype: 'textarea',
                name: 'supervision_details',
                id: 'supervision_details',
                width: '50%',
                allowBlank: false,
                msgTarget : 'qtip',
                value:this.supervision_details,
                width: '100%',
                margin:'10 0 10 0',
                labelSeparator: '',
                fieldLabel: '抽查详情记录:',
            }
            ]

        }
        let basicInformationListC={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[
                {
                    xtype: 'radiogroup',
                    fieldLabel: '是否下发整改',
                    id:'inspection_result',
                    margin:'10 0 10 0',
                    name:'inspection_result',
                    value:this.inspection_result?this.inspection_result:'1',
                    vertical: true,
                    items: [
                        { boxLabel: '是', inputValue: '1',margin:'2 0 0 0',id:'sfxxxgAA'},
                        { boxLabel: '否', inputValue: '2',margin:'2 0 0 20',id:'sfxxxgBB'}
                    ],
                    listeners :{
                        change:function(group,checked){
                            if(checked.inspection_result == 2){
                                Ext.getCmp('rectification_date').setDisabled(true);
                                Ext.getCmp('rectification_notice').setDisabled(true);
                                Ext.getCmp('rectification_reply').setDisabled(true);
                                Ext.getCmp('remarks').setDisabled(true);
                                Ext.getCmp('rectification_date').setValue('');
                                Ext.getCmp('rectification_notice').setValue('');
                                Ext.getCmp('remarks').setValue('');
                                Ext.getCmp('rectification_reply').setValue('');
                            }else{
                                Ext.getCmp('rectification_notice').setDisabled(false);
                                Ext.getCmp('rectification_reply').setDisabled(false);
                                Ext.getCmp('remarks').setDisabled(false);
                                Ext.getCmp('rectification_date').setDisabled(false);
                            }
                        },
                        render:function (value) {
                            var bizVal = value.initialConfig.value;
                            if(bizVal == 2){
                                Ext.getCmp('sfxxxgBB').setValue(true);
                            }else{
                                Ext.getCmp('sfxxxgAA').setValue(true);
                            }
                        }
                    }
                }
            ]

        }
        let basicInformationListD={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[ {
                xtype: 'textfield',
                name: 'rectification_notice',
                id: 'rectification_notice',
                msgTarget : 'qtip',
                value:this.rectification_notice,
                margin:'10 0 10 0',
                width: '50%',
                labelSeparator: '',
                fieldLabel: '整改通知单:'
            },{
                xtype: 'datefield',
                name: 'rectification_date',
                id: 'rectification_date',
                value:this.rectification_date,
                msgTarget : 'qtip',
                width: '50%',
                margin:'10 0 10 0',
                labelSeparator: '',
                editable:false,
                labelWidth:130,
                fieldLabel: '<span style="margin-left:30px; ">整改完成日期:</span>'
            }
            ]

        }
        let zghf={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            flex:2,
            items:[   {
                xtype: 'textarea',
                name: 'rectification_reply',
                id: 'rectification_reply',
                margin:'10 0 10 0',
                msgTarget : 'qtip',
                value:this.rectification_reply,
                width: '100%',
                labelSeparator: '',
                fieldLabel: '整改回复:',
            }
            ]

        }

        let basicInformationListE={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            flex:2,
            items:[  {
                xtype: 'textarea',
                name: 'remarks',
                id: 'remarks',
                allowBlank: false,
                msgTarget : 'qtip',
                value:this.remarks,
                width: '100%',
                margin:'10 0 10 0',
                labelSeparator: '',
                fieldLabel: '备注:',
            }
            ]

        }
        this.items = [basicInformationList,basicInformationListA,basicInformationListAA,basicInformationListB,basicInformationListC,basicInformationListD,zghf,basicInformationListE];
        this.callParent(arguments);
    }
});